package ru.rchervot.sanasar.client.view;

import ru.rchervot.sanasar.client.event.EventSelectedNone;
import ru.rchervot.sanasar.client.event.HandlerSelectedNone;

import com.google.gwt.event.shared.HandlerManager;

public class SelectedNonePresenter implements Presenter {

	public interface Display extends Presenter.Display {
		public void render(String queryDescription, int resultsSize);
	}
	
	protected final HandlerManager eventBus;
	protected final Display display;
	
	SelectedNonePresenter(Display display, HandlerManager eventBus) {
		this.display = display;
		this.eventBus = eventBus;
		
		listenForSelectedNone();
	}
		
	
	@Override
	public void bindDisplay() {
		display.setPresenter(this);
	}

	protected void listenForSelectedNone() {
		eventBus.addHandler(EventSelectedNone.getType(),
				new HandlerSelectedNone() {
			@Override
			public void onAction(
					EventSelectedNone event) {
				display.render(event.getQueryDescription(), event.getResultsSize());
			}
		});
	}
	
}
